import java.net.*;
import java.util.concurrent.ConcurrentHashMap;
import java.io.*;

public class Server extends Thread {

	private ServerSocket listener;
		
	public Server(int port) throws IOException {
		listener = new ServerSocket(port);
		System.out.println("Server IP address: " + listener.getInetAddress());
	}
	
	public void run() {
		for (;;) {
			Socket s = null;
			try {
				s = listener.accept();
			} catch (IOException e) {}
			if (s != null) {
				ProgramManager.activeConnections.put(s.getInetAddress(), new Connection(s));
			}
		}
	}
	
}
